<!-- 网络请求 -->
<template>
    <div class="doc-content-wrapper">
        <div class="doc-content-container">
            <div class="doc-content">
                <h1 class="text-4xl mb-6">网络请求</h1>

                <h2 class="mb-5 flex items-center"><a href="https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Promise/then" target="_blank">Promise.then()方法</a><el-tag class="ml-2">ES6</el-tag></h2>
                <p class="mb-3 text-base">then() 方法返回一个 Promise (en-US)。它最多需要有两个参数：Promise 的成功和失败情况的回调函数。</p>
                <Codemirror :code="thenCode" name="Promise.then()" class="mb-10" />


            </div>
        </div>
    </div>
</template>

<script lang="ts">
import { defineComponent, ref } from 'vue'

export default defineComponent({
    setup () {
        const thenCode = ref(`const promise1 = new Promise((resolve, reject) => {
  resolve('Success!');
});

promise1.then((value) => {
  console.log(value);
  // Expected output: "Success!"
});`)

        return {
            thenCode
        }
    }
})
</script>

<style scoped>

</style>